<template>
    <div>
        <el-dialog :title="isDetail ? '详情' : '审核'" :visible.sync="verifyDis" width="30%" @close="cancel" center>
            <el-form size="mini" :model="verifyForm" label-width="120px">
                <el-form-item label="标题：" prop="title">
                    <span>{{ verifyForm.title ? verifyForm.title : verifyForm.content.substring(0, 20) }}</span>
                </el-form-item>
                <el-form-item label="问题描述：" prop="content">
                    <span>{{ verifyForm.content }}</span>
                </el-form-item>
                <el-form-item label="精选：" prop="choiceAnswers">
                    <el-radio v-model="verifyForm.choiceAnswers" :label="1">是</el-radio>
                    <el-radio v-model="verifyForm.choiceAnswers" :label="0">否</el-radio>
                </el-form-item>
                <el-form-item label="虚拟热度：" prop="virtualCount">
                    <el-input v-model="verifyForm.virtualCount" placeholder="请输入虚拟浏览量"></el-input>
                </el-form-item>
                <el-form-item label="审核：" prop="verifyStatus">
                    <el-radio v-model="verifyForm.verifyStatus" :label="1">通过审核</el-radio>
                    <el-radio v-model="verifyForm.verifyStatus" :label="2">拒绝</el-radio>
                </el-form-item>
                <el-form-item>
                    <el-button @click="cancel()">取消</el-button>
                    <el-button :disabled="isDetail" type="primary" @click="onSubmit()">确定</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>

<script>
import {
    verifyArticleApi
} from "@/api/rank";
export default {
    data() {
        return {
            verifyDis: false,
            isDetail: false,
            verifyForm: {
                title: "",
                content: "",
                choiceAnswers: 1,
                virtualCount: '',
                verifyStatus: 1
            }
        }
    },
    methods: {
        onSubmit() {
            verifyArticleApi(this.verifyForm).then(res => {
                this.$message.success("审核成功！");
                this.cancel()
                this.$emit("getList");
            })
        },
        openDialog(v, type) {
            this.verifyDis = true
            this.verifyForm.title = v.title
            this.verifyForm.content = v.content
            this.verifyForm.id = v.id
            if (type == 'detail') {
                this.verifyForm = Object.assign({}, this.verifyForm, v)
                this.isDetail = true
            }
        },
        cancel() {
            this.verifyForm = {
                title: "",
                content: "",
                choiceAnswers: 1,
                virtualCount: '',
                verifyStatus: 1
            }
            this.verifyDis = false
            this.isDetail = false
        }
    }
}
</script>

<style></style>